<?php

use App\Admin\Controllers\CommentController;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use Encore\Admin\Facades\Admin;

Route::domain(config('admin.route.domain'))->group(function () {
    Admin::routes();

    Route::group([
        'prefix' => config('admin.route.prefix'),
        'namespace' => config('admin.route.namespace'),
        'middleware' => config('admin.route.middleware'),
        'as' => 'admin.'
    ], function (Router $router) {

        $router->get('/', 'HomeController@index')->name('home');
        $router->resource('products', 'ProductController');
        $router->resource('attributes', 'AttributeController');
        $router->resource('carousels', 'CarouselController')
            ->except(['show', 'destroy']);
        $router->resource('category', 'CategoryController')->except(['show']);
        $router->resource('coupons', 'CouponController')->except(['show', 'destroy']);
//        $router->resource('carts', 'CartController')->except(['show', 'destroy', 'edit']);
        $router->resource('customers', 'CustomerController')->except(['show', 'destroy', 'edit']);
        $router->resource('notices', 'NoticeController');
        $router->resource('tags', 'TagController');
        $router->resource('user-addresses', 'UserAddressController');
        $router->resource('skus', 'ProductSkuController')
            ->except('show');
        $router->resource('order', 'OrderController')->only(['index', 'show']);
        $router->resource('suggestions', 'SuggestionController')->only(['index']);
        $router->resource('comments', 'CommentController')->only(['index', 'destroy']);
        $router->resource('users', 'UserController')->except(['show', 'edit']);

        $router->group([
            'prefix' => "api"
        ], function (Router $router) {
            $router->get('products', 'ApiController@products')
                ->name('api.products');
            $router->get('attributes', 'ApiController@attributes')
                ->name('api.attributes');
            $router->get('carousel/type', 'ApiController@carouselType')
                ->name('api.carousel.type');
            $router->post('upload', 'ApiController@upload')
                ->name('api.upload');
        });

        $router->group([
            'prefix' => 'setting'
        ], function (Router $router) {
            $router->get('/', 'SettingController@index')->name('site.setting');
        });
    });
});
